<?php

namespace App\Http\Controller\Test;

use Swoft\Http\Server\Annotation\Mapping\Controller;
use Swoft\Apollo\Config;
use Swoft\Bean\Annotation\Mapping\Inject;
use Swoft\Rpc\Client\Annotation\Mapping\Reference;
use App\Rpc\Lib\UserInterface;

/**
 * Class BaseController
 * @Controller()
 */
class BaseController{

    /**
     * @Inject()
     *
     * @var Config
     */
    protected $config;

    /**
     * @Reference(pool="user.pool",version="2.0")
     * @var UserInterface
     */
    protected $service2User;

    /**
     * @Reference(pool="user.pool",version="1.0")
     * @var UserInterface
     */
    protected $serviceUser;

    /*
     * 上传文件到Fastdfs
     */
    protected function uploadFile($file){
        $fileName = $file->getClientFilename();
        $fileNameArr= explode(".",$fileName);
        $ext =array_pop($fileNameArr);
        $client = new \Eelly\FastDFS\Client(config('fastdfs'));
        return $client->uploadFile($file->getFile(),$ext);
    }
}